Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
validate-npm-package-license
Advanced tools
Give me a string and I'll tell you if it's a valid npm package license string
The validate-npm-package-license package is used to validate and parse license identifiers based on the SPDX license list. It helps ensure that package licenses are valid and SPDX-compliant, which is important for legal compliance and software distribution.
License Validation
This feature allows you to validate a string to check if it's a valid SPDX license expression. The code sample demonstrates how to validate the 'MIT' license identifier.
"use strict";\nconst validate = require('validate-npm-package-license');\nconst result = validate('MIT');\nconsole.log(result);
License Parsing
This feature enables parsing of complex SPDX license expressions, such as dual licenses. The code sample shows how to parse and validate a compound license expression that includes both 'MIT' and 'Apache-2.0' licenses.
"use strict";\nconst validate = require('validate-npm-package-license');\nconst result = validate('(MIT OR Apache-2.0)');\nconsole.log(result);
The spdx-correct package is designed to help correct invalid SPDX license IDs to their nearest valid identifiers. It is similar to validate-npm-package-license in that it deals with SPDX licenses, but it focuses more on correcting typos and common mistakes rather than validation.
This package provides functionality to parse SPDX license expressions, similar to one of the features of validate-npm-package-license. However, spdx-expression-parse focuses solely on parsing and does not include validation against the SPDX license list.
Give me a string and I'll tell you if it's a valid npm package license string.
var noWarnings = {
validForNewPackages: true,
validForOldPackages: true
};
// SPDX license identifier for common open-source licenses
valid('MIT'); // => noWarnings
valid('BSD-2-Clause'); // => noWarnings
valid('Apache-2.0'); // => noWarnings
valid('ISC'); // => noWarnings
// Simple SPDX license expression for dual licensing
valid('(GPL-3.0 OR BSD-2-Clause)'); // => noWarnings
// Refer to a non-standard license found in the package
valid('SEE LICENSE IN LICENSE.txt'); // => noWarnings
valid('SEE LICENSE IN license.md'); // => noWarnings
// No license
valid('UNLICENSED'); // => noWarnings
valid('UNLICENCED'); // => noWarnings
var warningsWithSuggestion = {
validForOldPackages: false,
validForNewPackages: false,
warnings: [
'license should be ' +
'a valid SPDX license expression without "LicenseRef", ' +
'"UNLICENSED", or ' +
'"SEE LICENSE IN <filename>"',
'license is similar to the valid expression "Apache-2.0"'
]
};
// Almost a valid SPDX license identifier
valid('Apache 2.0'); // => warningsWithSuggestion
var warningAboutLicenseRef = {
validForOldPackages: false,
validForNewPackages: false,
warnings: [
'license should be ' +
'a valid SPDX license expression without "LicenseRef", ' +
'"UNLICENSED", or ' +
'"SEE LICENSE IN <filename>"',
]
};
// LicenseRef-* identifiers are valid SPDX expressions,
// but not valid in package.json
valid('LicenseRef-Made-Up'); // => warningAboutLicenseRef
valid('(MIT OR LicenseRef-Made-Up)'); // => warningAboutLicenseRef
FAQs
Give me a string and I'll tell you if it's a valid npm package license string
The npm package validate-npm-package-license receives a total of 22,182,645 weekly downloads. As such, validate-npm-package-license popularity was classified as popular.
We found that validate-npm-package-license demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.